<?php
require_once MODEL_PATH.DS.'News.php';
$News = new News();
$cate_id = isset($_GET['cate_id'])?(int)$_GET['cate_id']:'';
$page = isset($_GET['page'])?(int)$_GET['page']:1;
$limit = 10;
$start = $page * $limit - $limit;
$category_list = $News->getAllNewsCate();
if($cate_id){
	$news_list = $News->getNewsByCateId($cate_id,$start,$limit);
	$num = $News->getNewsCountByCateId($cate_id);
}else{
	$news_list = $News->getAllNews($start,$limit);
	$num = $News->getAllNewsCount();
}
$url   = get_page_url();
$pages = get_pagehtml($num, $limit, $page, $url);
//var_dump($num, $limit, $page, $url,$pages);
$tpl->assign('category_list',$category_list);
$tpl->assign('news_list',$news_list);
$tpl->assign('pages',$pages);
$tpl->display('news_index.tpl');
?>